import {
  $wuxToast
} from '../../../es/index'
Page({
  data: {
    userInfo:{},
    canModify:false,
  },

  onLoad: function(options) {
    var that = this;
    this.setData({
      token: options.token
    });
    wx.showLoading({
      title: '加载中',
    });
    wx.request({
      //后期改成服务器路径
      // url: 'http://localhost/user/getBaseInfo',
      url: 'https://szsyph.cn/user/getBaseInfo',
      method: "GET",
      header: {
        'cookie': 'token=' + this.data.token
      },
      success(res) {
        var response = res.data;
        console.log(response);
        //获取信息成功
        if (response.code == 200) {
          that.setData({
            userInfo: response.data.baseInfo
          });
          wx.hideLoading();
        }
        //获取信息失败
        else{
          wx.hideLoading();
          that.showToastCancel("出错啦，请稍后再试");
        }
      },
      fail: function(res) {
        wx.hideLoading();
        that.showToastCancel("网络出现故障")
      }
    });
  },
  ChangeInfo:function(){
    this.setData({
      canModify:true
    })
  },
  SaveInfo:function(){
    this.setData({
      canModify:false
    })
  },
  showToastCancel(message) {
    $wuxToast().show({
      type: 'cancel',
      duration: 2500,
      color: '#fff',
      text: message,
    })
  },
})